/**
* @brief 组队副本
*/
#ifndef _SERVICE_TEAM_DUNGEON_H_
#define _SERVICE_TEAM_DUNGEON_H_

#include <unordered_map>
#include "../share/timer.h"
#include "../../3rd/libjson/json.h"

struct CPlayerHeroDamage
{
	int64_t damage_;	//总伤害
	std::map<int32_t, int32_t> hero_damage_;//英雄伤害
};

typedef std::unordered_map< int32_t, CPlayerHeroDamage > TPlayerDamageMap;
typedef std::unordered_map< int32_t, int32_t > TPlayerUpdateDamageTimeMap;

class CTeamDungeon;

enum EDungeonState
{
	EDungeon_None = 1,
	EDungeon_Start = 2,
	EDungeon_End = 3,
};

//副本结束时间
class CDungeonStopTimer : public ::common::CTimer
{
public:
	CDungeonStopTimer()
	{
		team_id_ = 0;
	}
public:
	void Init(int32_t teamid);
	virtual void TimerActive();
public:
	int32_t team_id_;
};

//血量更新器
class CDungeonHpNotify : public ::common::CTimer
{
public:
	CDungeonHpNotify(CTeamDungeon& team_dungeon):team_dungeon_(team_dungeon)
	{
		
	}
public:
	virtual void TimerActive();
public:
	CTeamDungeon& team_dungeon_;
};

//只支持打一个大boss的组队副本
class CTeamDungeon
{
public:
	CTeamDungeon();
public:
	void PlayerEnterBoss(int32_t playerid, int32_t heroid1, int32_t heroid2, int32_t heroid3);
	void AddPlayerDamage(int32_t playerid, int32_t damage, Json::Value& damagelist);
	void BossReduceHp(int32_t playerid, int32_t damage);
	void StartBoss(int32_t boss_id, int32_t boss_lv, int32_t team_id);
	bool isDie();

	void BossDieNotify();
	void onBossEnd(bool bossdie);
	void KillBoss(int32_t playerId);

	int32_t boss_id() { return boss_id_; }
	int32_t boss_lv() { return boss_lv_; }
	int64_t boss_max_hp() { return boss_max_hp_; }
	int64_t boss_cur_hp() { return boss_cur_hp_; }
	int32_t dungeon_state() { return dungeon_state_; }

	void NotifyPlayer(int32_t msgid, Json::Value& notify);
private:
	int64_t boss_max_hp_;
	int64_t	boss_cur_hp_;
	int32_t boss_id_;
	int32_t boss_lv_;
	int32_t activity_id_;	//活动ID
	TPlayerDamageMap player_damage_map_;
	int32_t dungeon_state_;
	CDungeonStopTimer stop_timer_;
	CDungeonHpNotify hp_notify_timer_;
	int32_t team_id_;
};

#endif

